import 'package:cbec_app/components/base/base_image.dart';
import 'package:cbec_app/components/base/base_interactive.dart';
import 'package:cbec_app/components/common/common_style.dart';
import 'package:cbec_app/routes/routes.dart';
import 'package:cbec_app/utils/AppData.dart';
import 'package:cbec_app/utils/ThemeConfig.dart';
import 'package:cbec_app/utils/Tools.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';

import '../../pages/goods/binding/goods_detail_binding.dart';
import '../../pages/goods/view/goods_detail_page.dart';

///店铺装修-商品
class DecorationGoods extends StatefulWidget {
  ///商品配置信息
  final Map<String, dynamic> info;

  ///商品id key值
  final String idKey;

  ///商品现价 key值
  final String curPriceKey;

  ///商品原价 key值
  final String originPriceKey;

  ///商品列表
  final List goodsList;

  ///商品类型 0-普通商品 1-特价商品 2-拼团商品 3-秒杀商品 4-砍价商品 5-预售商品
  final int goodsType;

  const DecorationGoods({
    super.key,
    required this.info,
    required this.goodsList,
    this.idKey = 'id',
    this.curPriceKey = 'price',
    this.originPriceKey = 'priceMarket',
    this.goodsType = 0,
  });

  @override
  State<StatefulWidget> createState() {
    return _DecorationGoodsState();
  }
}

class _DecorationGoodsState extends State<DecorationGoods> {
  @override
  void initState() {
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return getBox();
  }

  ///获取容器
  Widget getBox() {
    switch (widget.info['size']) {
      case '2': //一行两个
        return Container(
            margin: EdgeInsets.only(left: getMargin(), right: getMargin()),
            width: getCanUsedWidth(),
            child: Wrap(
              alignment: WrapAlignment.spaceBetween,
              runSpacing: getItemMargin(),
              children: getList().map((item) => decorationGoodsItem(item, getUseTextWidth(), getUseTextWidth())).toList(),
            ));
      case '3': //一行3个
        return Container(
          margin: EdgeInsets.only(left: getMargin(), right: getMargin()),
          width: getCanUsedWidth(),
          child: Wrap(
            alignment: WrapAlignment.start,
            runSpacing: getItemMargin(),
            children: List.generate(getList().length, (index) => decorationGoodsItem(getList()[index], getUseTextWidth(), getUseTextWidth(), index: index)),
          ),
        );
      case '4': //大图模式
        return Container(
            margin: EdgeInsets.only(left: getMargin(), right: getMargin()),
            child: Wrap(
              direction: Axis.vertical,
              spacing: getItemMargin(),
              children: getList().map((item) => decorationGoodsItem(item, getUseTextWidth(), getUseTextWidth())).toList(),
            ));
      case '5': //横向滑动
        return Container(
            margin: EdgeInsets.only(left: getMargin()),
            child: SingleChildScrollView(
              scrollDirection: Axis.horizontal,
              child: Row(
                children: getList().map((item) => decorationGoodsItem(item, getUseTextWidth(), getUseTextWidth())).toList(),
              ),
            ));
      case '6': //一大两小
        return Container(
            margin: EdgeInsets.only(left: getMargin()),
            child: Wrap(
              direction: Axis.vertical,
              spacing: getItemMargin(),
              children: renderOneBigTwoSmall(),
            ));
      case '1': //一行一个
        return Container(
            margin: EdgeInsets.only(left: getMargin(), right: getMargin()),
            child: Wrap(
              direction: Axis.vertical,
              spacing: getItemMargin(),
              children: getList().map((item) => decorationGoodsItem(item, 138, getUseTextWidth())).toList(),
            ));
      default:
        return Container(
            margin: EdgeInsets.only(left: getMargin(), right: getMargin()),
            color: Colors.white,
            child: Wrap(
              direction: Axis.vertical,
              spacing: getItemMargin(),
              children: getList().map((item) => decorationGoodsItem(item, 138, getUseTextWidth())).toList(),
            ));
    }
  }

  ///渲染一大两小商品
  List<Widget> renderOneBigTwoSmall() {
    List<Widget> arr = [];
    for (int i = 0; i < getList().length; i += 3) {
      if (i + 1 < getList().length && i + 2 < getList().length) {
        arr.add(decorationGoodsItem(getList()[i], getUseTextWidth(), getUseTextWidth(), item1: getList()[i + 1], item2: getList()[i + 2]));
      }
    }
    return arr;
  }

  ///获取商品列表
  List getList() {
    return widget.goodsList;
  }

  ///装修商品item
  Widget decorationGoodsItem(
    Map<String, dynamic> item,
    double imgWidth,
    double textWidth, {
    Map<String, dynamic>? item1,
    Map<String, dynamic>? item2,
    int? index = 0,
  }) {
    //print('装修商品item ===================${item}');

    switch (widget.info['size']) {
      case '2': //一行两个
        return BaseInteractive(
          childWidget: Container(
            width: imgWidth,
            decoration: getBoxDecoration(),
            child: Column(
              mainAxisAlignment: MainAxisAlignment.start,
              children: [
                goodsImg(item, imgWidth),
                goodsName(item, textWidth, margin: const EdgeInsets.only(top: 8)),
                Container(
                  padding: const EdgeInsets.only(left: 8, right: 8),
                  width: textWidth,
                  child: Wrap(
                    runSpacing: 2.w,
                    children: item['discountLabel'] == null
                        ? 0
                        : item['discountLabel']
                            .map<Widget>(
                              (text) => BorderedText(
                                text: text,
                                padding: const EdgeInsets.only(left: 2, right: 2, top: 2, bottom: 2),
                                borderColor: ThemeConfig.themeColor,
                                textStyle: const TextStyle(fontSize: 11, color: ThemeConfig.themeColor),
                              ),
                            )
                            .toList(),
                  ),
                ),
                goodsStorage(item, textWidth, margin: const EdgeInsets.only(top: 8)),
                Container(
                  width: textWidth,
                  margin: const EdgeInsets.only(top: 8, bottom: 8),
                  padding: const EdgeInsets.only(left: 8, right: 8),
                  child: Row(
                    mainAxisAlignment: getPriceAlignStyle(),
                    children: [goodsPrice(item), carIcon()],
                  ),
                ),
              ],
            ),
          ),
          onClick: () {
            jumpDetail(item);
          },
        );
      case '3': //一行3个
        return BaseInteractive(
          childWidget: Container(
            width: imgWidth,
            decoration: getBoxDecoration(),
            margin: EdgeInsets.only(right: (index! + 1) % 3 == 0 ? 0 : getItemMargin()),
            child: Column(
              mainAxisAlignment: MainAxisAlignment.start,
              children: [
                goodsImg(item, imgWidth),
                Container(
                  child: Column(
                    children: [
                      goodsName(item, textWidth),
                      Container(
                        padding: const EdgeInsets.only(left: 8, right: 8),
                        width: textWidth,
                        height: 45,
                        child: Wrap(
                          runSpacing: 2.w,
                          children: [
                            if (item['discountLabel'] != null && item['discountLabel'].isNotEmpty)
                              for (var text in item['discountLabel'])
                                BorderedText(
                                  text: text,
                                  padding: const EdgeInsets.only(left: 2, right: 2, top: 2, bottom: 2),
                                  borderColor: ThemeConfig.themeColor,
                                  textStyle: const TextStyle(fontSize: 11, color: ThemeConfig.themeColor),
                                ),
                          ],
                        ),
                      ),
                      goodsStorage(item, textWidth),
                      Container(
                        width: textWidth,
                        margin: const EdgeInsets.only(top: 8, bottom: 8),
                        padding: const EdgeInsets.only(left: 8, right: 8),
                        child: Row(
                          mainAxisAlignment: getPriceAlignStyle(),
                          children: [goodsPrice(item), carIcon()],
                        ),
                      ),
                    ],
                  ),
                )
              ],
            ),
          ),
          onClick: () {
            jumpDetail(item);
          },
        );
      case '4': //大图模式
        return BaseInteractive(
          childWidget: Container(
            width: imgWidth,
            decoration: getBoxDecoration(),
            child: Column(
              mainAxisAlignment: MainAxisAlignment.start,
              children: [
                goodsImg(item, imgWidth),
                goodsName(item, textWidth, maxLines: 1, isBigPic: true),
                Container(
                  padding: const EdgeInsets.only(left: 8, right: 8),
                  width: textWidth,
                  child: Wrap(
                    runSpacing: 8.w,
                    children: [
                      if (item['discountLabel'] != null && item['discountLabel'].isNotEmpty)
                        for (var text in item['discountLabel'])
                          BorderedText(
                            text: text,
                            padding: const EdgeInsets.only(left: 2, right: 2, top: 2, bottom: 2),
                            borderColor: ThemeConfig.themeColor,
                            textStyle: const TextStyle(fontSize: 11, color: ThemeConfig.themeColor),
                          ),
                    ],
                  ),
                ),
                goodsStorage(item, textWidth),
                Container(
                  width: textWidth,
                  margin: const EdgeInsets.only(top: 8),
                  padding: const EdgeInsets.only(left: 8, right: 8),
                  child: Row(
                    mainAxisAlignment: getPriceAlignStyle(),
                    children: [goodsPrice(item), carIcon()],
                  ),
                )
              ],
            ),
          ),
          onClick: () {
            jumpDetail(item);
          },
        );
      case '5': //横向滑动
        return BaseInteractive(
          childWidget: Container(
            width: imgWidth,
            decoration: getBoxDecoration(),
            margin: EdgeInsets.only(right: getItemMargin()),
            child: Column(
              mainAxisAlignment: MainAxisAlignment.start,
              children: [
                goodsImg(item, imgWidth),
                Container(
                  color: Colors.white,
                  child: Column(
                    children: [
                      goodsName(item, textWidth),
                      Container(
                        padding: const EdgeInsets.only(left: 8, right: 8),
                        width: textWidth,
                        height: 45,
                        child: Wrap(
                          runSpacing: 2.w,
                          children: [
                            if (item['discountLabel'] != null && item['discountLabel'].isNotEmpty)
                              for (var text in item['discountLabel'])
                                BorderedText(
                                  text: text,
                                  padding: const EdgeInsets.only(left: 2, right: 2, top: 2, bottom: 2),
                                  borderColor: ThemeConfig.themeColor,
                                  textStyle: const TextStyle(fontSize: 11, color: ThemeConfig.themeColor),
                                ),
                          ],
                        ),
                      ),
                      goodsStorage(item, textWidth),
                      Container(
                        width: textWidth,
                        margin: const EdgeInsets.only(top: 8, bottom: 8),
                        padding: const EdgeInsets.only(left: 8, right: 8),
                        child: Row(
                          mainAxisAlignment: getPriceAlignStyle(),
                          children: [goodsPrice(item), carIcon()],
                        ),
                      ),
                    ],
                  ),
                )
              ],
            ),
          ),
          onClick: () {
            jumpDetail(item);
          },
        );
      case '6': //一大两小
        return Container(
          width: imgWidth,
          decoration: getBoxDecoration(),
          child: Column(
            mainAxisAlignment: MainAxisAlignment.start,
            children: [
              BaseInteractive(
                childWidget: Column(
                  mainAxisAlignment: MainAxisAlignment.start,
                  children: [
                    goodsImg(item, imgWidth),
                    goodsName(item, imgWidth, maxLines: 1, isBigPic: true),
                    Container(
                      padding: const EdgeInsets.only(left: 8, right: 8),
                      width: textWidth,
                      child: Wrap(
                        runSpacing: 8.w,
                        children: [
                          if (item['discountLabel'] != null && item['discountLabel'].isNotEmpty)
                            for (var text in item['discountLabel'])
                              goodsDetailTypeTag(
                                text,
                                margin: EdgeInsets.only(right: 8.w),
                              ),
                        ],
                      ),
                    ),
                    goodsStorage(item, imgWidth),
                    Container(
                      width: textWidth,
                      margin: const EdgeInsets.only(top: 8),
                      padding: const EdgeInsets.only(left: 8, right: 8),
                      child: Row(
                        mainAxisAlignment: getPriceAlignStyle(),
                        children: [goodsPrice(item), carIcon()],
                      ),
                    )
                  ],
                ),
                onClick: () {
                  jumpDetail(item);
                },
              ),
              SizedBox(
                height: getItemMargin(),
              ),
              Row(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: [
                  Container(
                    decoration: getBoxDecoration(),
                    child: BaseInteractive(
                      childWidget: Column(
                        mainAxisAlignment: MainAxisAlignment.start,
                        children: [
                          goodsImg(item1!, (imgWidth - getItemMargin()) / 2),
                          goodsName(item1, (imgWidth - getItemMargin()) / 2),
                          Container(
                            padding: const EdgeInsets.only(left: 8, right: 8),
                            width: ((imgWidth - getItemMargin()) / 2),
                            child: Wrap(
                              runSpacing: 8.w,
                              children: [
                                for (var text in item['discountLabel'])
                                  goodsDetailTypeTag(
                                    text,
                                    margin: EdgeInsets.only(right: 8.w),
                                  ),
                              ],
                            ),
                          ),
                          goodsStorage(item1, (imgWidth - getItemMargin()) / 2),
                          Container(
                            width: (imgWidth - getItemMargin()) / 2,
                            margin: const EdgeInsets.only(top: 8),
                            padding: const EdgeInsets.only(left: 8, right: 8),
                            child: Row(
                              mainAxisAlignment: getPriceAlignStyle(),
                              children: [goodsPrice(item1), carIcon()],
                            ),
                          )
                        ],
                      ),
                      onClick: () {
                        jumpDetail(item1);
                      },
                    ),
                  ),
                  Container(
                    decoration: getBoxDecoration(),
                    child: BaseInteractive(
                      childWidget: Column(
                        mainAxisAlignment: MainAxisAlignment.start,
                        children: [
                          goodsImg(item2!, (imgWidth - getItemMargin()) / 2),
                          goodsName(item2, (imgWidth - getItemMargin()) / 2),
                          SizedBox(
                            width: ((imgWidth - getItemMargin()) / 2),
                            child: Wrap(
                              runSpacing: 8.w,
                              children: [
                                if (item['discountLabel'] != null && item['discountLabel'].isNotEmpty)
                                  for (var text in item['discountLabel'])
                                    goodsDetailTypeTag(
                                      text,
                                      margin: EdgeInsets.only(right: 8.w),
                                    ),
                              ],
                            ),
                          ),
                          goodsStorage(item2, (imgWidth - getItemMargin()) / 2),
                          Container(
                            width: (imgWidth - getItemMargin()) / 2,
                            margin: const EdgeInsets.only(top: 8),
                            child: Row(
                              mainAxisAlignment: getPriceAlignStyle(),
                              children: [goodsPrice(item2), carIcon()],
                            ),
                          )
                        ],
                      ),
                      onClick: () {
                        jumpDetail(item2);
                      },
                    ),
                  )
                ],
              ),
              SizedBox(
                height: getItemMargin(),
              ),
            ],
          ),
        );

      case '1': //一行一个
      default:
        return BaseInteractive(
          childWidget: Container(
            width: imgWidth + textWidth + 8,
            decoration: getBoxDecoration(),
            child: Row(
              children: [
                goodsImg(item, imgWidth),
                const SizedBox(
                  width: 8,
                ),
                Column(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: [
                    Column(
                      mainAxisAlignment: MainAxisAlignment.start,
                      children: [
                        goodsName(item, textWidth),
                        Container(
                          padding: const EdgeInsets.only(left: 8, right: 8),
                          width: textWidth,
                          child: Wrap(
                            runSpacing: 8.w,
                            children: [
                              if (item['discountLabel'] != null && item['discountLabel'].isNotEmpty)
                                for (var text in item['discountLabel'])
                                  goodsDetailTypeTag(
                                    text,
                                    margin: EdgeInsets.only(right: 8.w),
                                  ),
                            ],
                          ),
                        ),
                        goodsStorage(item, textWidth),
                      ],
                    ),
                    const SizedBox(
                      height: 40,
                    ),
                    Container(
                      padding: const EdgeInsets.only(left: 8, right: 8),
                      width: textWidth,
                      child: Row(
                        mainAxisAlignment: getPriceAlignStyle(),
                        children: [goodsPrice(item), carIcon()],
                      ),
                    )
                  ],
                )
              ],
            ),
          ),
          onClick: () {
            jumpDetail(item);
          },
        );
    }
  }

  ///获取价格对齐样式
  MainAxisAlignment getPriceAlignStyle() {
    switch (widget.info['text_align_type']) {
      case 'center':
        return MainAxisAlignment.center;
      case 'right':
        return MainAxisAlignment.end;

      case 'left':
      default:
        return MainAxisAlignment.spaceBetween;
    }
  }

  ///获取商品名称对齐方式
  TextAlign getNameAlignStyle() {
    switch (widget.info['text_align_type']) {
      case 'center':
        return TextAlign.center;
      case 'right':
        return TextAlign.right;

      case 'left':
      default:
        return TextAlign.left;
    }
  }

  ///获取商品装饰样式
  BoxDecoration getBoxDecoration() {
    // print('无边白底,透明度 ---- ${widget.info['size_type'].toString()}');

    switch (widget.info['size_type'].toString()) {
      case '1': //卡片阴影
        return BoxDecoration(boxShadow: [BoxShadow(color: Tools.fromHex('#646566').withOpacity(0.12), offset: const Offset(0, 2), blurRadius: 12)], color: Colors.white);
      case '2': //描边白底
        return BoxDecoration(border: Border.all(color: Tools.fromHex('#ebedf0'), width: 0.5), color: Colors.white);
      case '0': //无边白底,透明度
        return const BoxDecoration(color: Colors.white);
      case '3':
      // print('无边白底,透明度');
      // return const BoxDecoration();
      default:
        return const BoxDecoration();
    }
  }

  ///跳转商品详情
  void jumpDetail(Map<String, dynamic> item) {
    if (AppData.isLogin) {
      final id = item[widget.idKey];
      Get.to(
        () => GoodsDetailPage(flag: id), // 使用函数懒加载页面实例
        routeName: '${Routes.goodsDetail}?unique=${DateTime.now().millisecondsSinceEpoch}',
        arguments: {"id": id}, // 传递其它参数
        binding: GoodsDetailBinding(flag: id), // 将 tag 参数传递给绑定类
      );
    } else {
      Get.toNamed(Routes.login);
    }
  }

  ///获取容器可用宽度
  double getCanUsedWidth() {
    return (375.w - getMargin() * 2).floorToDouble();
  }

  ///获取文本可用宽度
  double getUseTextWidth() {
    switch (widget.info['size']) {
      case '2': //一行两个
        return ((375.w - getMargin() * 2 - getItemMargin()) / 2).floorToDouble();
      case '3': //一行3个
        return ((375.w - getMargin() * 2 - getItemMargin() * 2) / 3).floorToDouble();
      case '4': //大图模式
        return (375.w - getMargin() * 2).floor().floorToDouble();
      case '5': //横向滑动
        return ((375.w - getMargin() - getItemMargin() * 3 - 30) / 3).floorToDouble();
      case '6': //一大两小
        return (375.w - getMargin() * 2).floorToDouble();
      case '1': //一行一个
      default:
        //138图片宽度 8间距
        return (375.w - getMargin() * 2 - 138 - 8).floorToDouble();
    }
  }

  ///页面margin
  double getMargin() {
    return double.parse(widget.info['page_margin'].toString());
  }

  ///商品间距
  double getItemMargin() {
    return double.parse(widget.info['goods_margin'].toString());
  }

  ///商品图片
  Widget goodsImg(Map<String, dynamic> item, double width) {
    switch (widget.info['image_fill_style'].toString()) {
      case '1': //周边留白
        return Container(
            color: Colors.white,
            width: width,
            height: getImgHeight(width),
            alignment: Alignment.center,
            child: Stack(
              children: [
                BaseImage(
                  url: getUrl(item),
                  width: width * 0.9,
                  height: getImgHeight(width) * 0.9,
                  borderRadius: BorderRadius.circular(getRadius()),
                ),
                //商品角标
                widget.info['show_corner_mark'] == '1' ? getBadge(item) : emptyWidget()
              ],
            ));
      case '0': //图片填充
      default:
        return Container(
            color: Colors.transparent,
            width: width,
            height: getImgHeight(width),
            child: Stack(
              children: [
                AspectRatio(
                  aspectRatio: width / getImgHeight(width),
                  child: BaseImage(
                    url: getUrl(item),
                    // width: width,
                    // height: getImgHeight(width),
                    // fit: BoxFit.fill,
                    borderRadius: BorderRadius.circular(getRadius()),
                  ),
                ),
                //商品角标
                widget.info['show_corner_mark'] == '1' ? getBadge(item) : emptyWidget()
              ],
            ));
    }
  }

  ///获取商品图片url
  String getUrl(Map<String, dynamic> item) {
    var images = item['image'];
    if (images is List && images.isNotEmpty) {
      return images[0];
    }
    return item['mainImage'];
  }

  ///获取商品高度
  double getImgHeight(double width) {
    switch (widget.info['display_scale']) {
      case '0': //3:2
        return width * 2 / 3;
      case '2': //3:4
        return width * 3 / 4;
      case '3': //16:9
        return width * 16 / 9;
      case '1': //1:1
      default:
        return width;
    }
  }

  ///获取角标url
  String getBadgeUrl(Map<String, dynamic> item) {
    switch (widget.info['corner_mark_type']) {
      case '1': //热卖
        return 'hot_ch.png';
      case '2': //NEW
        return 'new.png';
      case '3': //HOT
        return 'hot.png';
      case '4': //自定义
        return widget.info['corner_mark_image'];
      case '0': //新品
      default:
        return 'new_ch.png';
    }
  }

  ///获取角标
  Widget getBadge(Map<String, dynamic> item) {
    return Positioned(
        top: 0,
        left: 0,
        child: Container(
          alignment: Alignment.center,
          width: 40,
          height: 40,
          child: BaseImage(
            url: getBadgeUrl(item),
            width: 32,
            height: 32,
          ),
        ));
  }

  ///商品图片圆角
  double getRadius() {
    return widget.info['border_radius_type'] == '1' ? 0.0 : 3.0;
  }

  ///商品名称(最多两行)
  Widget goodsName(Map<String, dynamic> item, double width, {int maxLines = 2, EdgeInsetsGeometry? margin, bool? isBigPic = false}) {
    return widget.info['title'] == '1'
        ? Container(
            width: width,
            height: isBigPic == false ? (maxLines == 2 ? 55.0 : 25.0) : null,
            margin: margin,
            child: Padding(
              padding: const EdgeInsets.all(8.0),
              child: RichText(
                maxLines: maxLines,
                textAlign: getNameAlignStyle(),
                overflow: TextOverflow.ellipsis, // 超过部分显示省略号
                text: TextSpan(
                  children: [
                    WidgetSpan(
                      alignment: PlaceholderAlignment.middle, // 垂直居中对齐
                      child: goodsTypeTag(
                        getGoodsTypeName(item['commodityType']),
                        margin: const EdgeInsets.only(right: 5), // 设置右边距
                      ),
                    ),
                    TextSpan(
                      text: item['commodityName'],
                      style: TextStyle(
                        fontSize: 14,
                        fontWeight: widget.info['text_style_type'] == '1' ? FontWeight.normal : FontWeight.bold,
                        overflow: TextOverflow.ellipsis,
                        color: Tools.fromHex('#3D3D3D'),
                      ),
                    ),
                  ],
                ),
              ),
            ),
          )
        : emptyWidget();
  }

  ///商品库存
  Widget goodsStorage(Map<String, dynamic> item, double width, {EdgeInsetsGeometry? margin}) {
    return widget.info['show_stock_num'] == '1'
        ? Container(
            width: width,
            margin: margin,
            // height: 21,
            child: Text(
              '仅剩${item['storage'].toString()}件',
              style: const TextStyle(fontSize: 12, color: Color(0xff969799)),
              maxLines: 1,
              overflow: TextOverflow.ellipsis,
            ),
          )
        : emptyWidget();
  }

  ///商品价格
  Widget goodsPrice(Map<String, dynamic> item) {
    return widget.info['price'] == '1'
        ? Row(
            children: [
              Text('￥', style: TextStyle(fontSize: 12, color: ThemeConfig.themeColor, fontWeight: widget.info['text_style_type'] == '1' ? FontWeight.normal : FontWeight.bold)),
              Text(
                getPrice(item),
                style: TextStyle(fontSize: 15, color: ThemeConfig.themeColor, fontWeight: widget.info['text_style_type'] == '1' ? FontWeight.normal : FontWeight.bold),
              ),
              //原价
              (widget.info['show_origin_price'] == '1' || widget.info['origin_price'] == '1')
                  ? Padding(
                      padding: EdgeInsets.only(left: 5),
                      child: Text(
                        getPriceMarket(item),
                        style: TextStyle(color: Color(0xff969799), fontWeight: widget.info['text_style_type'] == '1' ? FontWeight.normal : FontWeight.bold, fontSize: 9, decoration: TextDecoration.lineThrough),
                      ))
                  : emptyWidget(),
              const SizedBox(
                width: 10,
              )
            ],
          )
        : emptyWidget();
  }

  ///获取商品现价
  String getPrice(Map<String, dynamic> item) {
    return item[widget.curPriceKey] != null ? item[widget.curPriceKey].toString() : item['specList'][0]['price'].toString();
  }

  ///获取商品划线价
  String getPriceMarket(Map<String, dynamic> item) {
    return item[widget.originPriceKey] != null ? item[widget.originPriceKey].toString() : item['specList'][0]['priceMarket'].toString();
  }

  ///购物车图标
  Widget carIcon() {
    // return const Icon(
    //   Icons.shopping_cart,
    //   size: 21,
    //   color: ThemeConfig.themeColor,
    // );
    return emptyWidget();
  }
}
